const mongoose = require('mongoose')

const Schema = mongoose.Schema

const RoleSchema = new Schema({
  name: {
    type: String,
    require: true,
    unique: true,
  },
})

const RoleModel = mongoose.model('Role', RoleSchema)

RoleModel.findOne({
  name: '管理员',
}).then(res => !res && RoleModel.create({ name: '管理员' }, { name: '普通用户' }))

module.exports = RoleModel
